package com.findsing.jetty.websocket.async;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.AsyncContext;
import javax.ws.rs.core.MediaType;


public class AsyncProcesser {
	public void process(final AsyncContext ctx){
		/*Message message = new Message();
		message.setMessageName("Hello");*/
		
		try {
			Thread.sleep(3*1000);
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}
		
		ctx.getResponse().setContentType(MediaType.APPLICATION_JSON);
		try (final PrintWriter w = ctx.getResponse().getWriter()) {
            w.printf("{\"greeting\": \"%s\", \"name\": \"%s\"}", "Hello", "Jeff");
        } catch (IOException e) {
            e.printStackTrace(System.err);
        }
		ctx.complete();
	}
}
